import type { API as GSTCAPI } from 'gantt-schedule-timeline-calendar';
import { BLOG_STATUS } from '@/constants/common/blog-status';

declare global {
  interface Window {
    gstc?: GSTCAPI;
  }
}

export interface Topic {
  id: string;
  name: string;
  priority: number;
  progress: number; // 0-100
  startDate: string | Date; // ISO date string or Date object
  endDate: string | Date; // ISO date string or Date object
}

export interface BlogPost {
  id: string;
  collectionId: string;
  title: string;
  // category: string;
  // content: string;
  author: string;
  wordCount: number;
  status: BLOG_STATUS;
  progress: number; // 0-100
  startDate: string | Date; // ISO date string or Date object
  endDate: string | Date; // ISO date string or Date object
  summary?: string;
  contentLink: string;
  tags?: string[];
  startTime?: number;
  endTime?: number;
  dependant?: string[];
  createdAt: string;
  updatedAt: string;
}

export interface PostDependency {
  id: string;
  sourcePost: string;
  targetPost: string;
  relationType: 'finish-to-start' | 'start-to-start' | 'finish-to-finish' | 'start-to-finish';
  createdAt: string;
}

export interface PostMilestone {
  id: string;
  postId?: string;
  name: string;
  date: string | Date; // ISO date string
  priority: number; // 1-3
  description?: string;
  completed: boolean;
  createdAt: string;
}

export interface GanttState {
  posts: BlogPost[];
  dependencies: PostDependency[];
  milestones: PostMilestone[];
  zoomLevel: 'day' | 'week' | 'month';
  activePostId: string | null;
  creatingDependency: {
    sourceId: string | null;
  };
  isLoading: boolean;
  error: string | null;
}
